<?php
namespace Home\Controller;
use Think\Controller;
class MyorderController extends PublicController {
    public function userorder(){
		
		$this->assign("k",CONTROLLER_NAME);
		$this->assign("f",ACTION_NAME);
		$this->messg();
		$this->wxjshow();
		$this->display();
    }
	//个人信息及订单信息输出
	/* public function messg(){
		$user_name = session('name');
		//个人信息
		$info = M('user')->field("truename,name")->where("name = '$user_name'")->find();
		$this->assign("truename",$info['truename']);
		$name = $info['name'];
		//订单信息
		$res = M('order')->where("user = '$name'")->select();
		$this->assign("res",$res);
	} */
	//个人信息及订单信息输出
	public function messg(){
		$user_name = session('name');
		//个人信息
		$info = M('user')->field("truename,name")->where("name = '$user_name'")->find();
		$this->assign("truename",$info['truename']);
		$name = $info['name'];
		//订单号信息
		$res = M('order')->where("user = '$name'")->select();
		//var_dump($res);
		//默认地址信息
		$address = M('shopaddress')->where("status = '1'")->find();
		//订单具体内容输出
		foreach($res as $k=>$v){
			$p_id = $v['p_id'];
			$p_ids = explode(",",$p_id);
			//var_dump($p_ids);
			$order_number = $v['order_number'];
			//var_dump($p_ids);
			foreach($p_ids as $k1=>$v1){
				$id = (int)$v1;
				//var_dump($id);
				$resinfo = M("listinfo")->where("id = $id")->find();
				//var_dump($resinfo);
				
				$res[$k][$order_number][$k1] = $resinfo;
				//var_dump($res);
			}
		}
		//var_dump($res);
		$this->assign("res",$res);
		$this->assign("address",$address);
		
	}
}